#ifndef __RAWSOCKET_H_
#define __RAWSOCKET_H_
#include "KLib.h"
#include "winsock2.h"
#include "ws2tcpip.h"
SK


typedef struct _IPPacket
{
    byte lenAndVer;
    byte tos;
    u16 length;
    u16 identification;
    u16 flag_offset;
    byte ttl;
    byte protocol;
    u16 checksum;
    u32 ucSource;
    u32 ucDestination;
}IPPacket;

typedef struct _ICMPPacket
{
    byte msgType;
    byte code;
    u16 checksum;
    u16 id;
    u16 seq;
}ICMPPacket;




class RawSocket
{
private:
    int protocol;
    SOCKET soc;

    int err;
public:
    RawSocket (int protocol);
    ~RawSocket ();

    bool sendTo (byte *data, u32 length, const String& dest);
    int recvFrom (byte *buf, u32 bufSize, const String& from);

    static u16 calculateIPChecksum (byte *packet, int length);
};

EK
#endif